//
//  AllLableCell.m
//  JinChengYun
//
//  Created by 金橙云 on 2017/4/8.
//  Copyright © 2017年 金橙云. All rights reserved.
//
#define Q_WIDTH self.frame.size.width

#define S_Lab (Q_WIDTH/4)
#import "AllLableCell.h"

@implementation AllLableCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self)
    {
        
        int AK =([UIScreen mainScreen].bounds.size.width)/4;


        __weak typeof(self) weakSelf = self; //对self进行weak化，否则造成循环引用无法释放controller
        
        UILabel * tempView = [[UILabel alloc]init];
        NSInteger count = 3;//设置一排view的个数
        NSInteger margin = AK;//设置相隔距离
        NSInteger height = 30;//设置view的高度
        for (int i = 0; i < 3; i ++) {
            UILabel *shuLab = [[UILabel alloc] init];
            shuLab.backgroundColor = [UIColor grayColor];
            [self addSubview:shuLab];
            if (i == 0) {
                [shuLab mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.equalTo(weakSelf).offset(margin);
                    // make.centerY.equalTo(weakSelf);
                    make.height.mas_equalTo(height);
                    make.top.mas_equalTo(self.mas_top);
                    make.size.mas_equalTo(CGSizeMake(0.5f, 30));
                }];
            }
            else if (i == count -1){
                [shuLab mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.right.equalTo(weakSelf).offset(-margin);
                    make.left.equalTo(tempView.mas_right).offset(margin);
                    // make.centerY.equalTo(tempView);
                    make.height.equalTo(tempView);
                    make.width.equalTo(tempView);
                    make.top.mas_equalTo(self.mas_top);
                    make.size.mas_equalTo(CGSizeMake(0.5f, 30));
                }];
            }
            else{
                [shuLab mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.left.equalTo(tempView.mas_right).offset(margin);
                    //make.centerY.equalTo(tempView);
                    make.height.equalTo(tempView);
                    make.width.equalTo(tempView);
                    make.top.mas_equalTo(self.mas_top);
                    make.size.mas_equalTo(CGSizeMake(0.5f, 30));
                }];
            }
            tempView = shuLab;
            [shuLab layoutIfNeeded];
        }
        


        _oneDLab = [[UILabel alloc] init];
        _oneDLab.textColor = [UIColor blackColor];
        _oneDLab.text = @"实收房款";
        _oneDLab.textAlignment = NSTextAlignmentCenter;
        _oneDLab.font = [UIFont systemFontOfSize:12];
        [self addSubview:_oneDLab];
        [_oneDLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(AK, 20));
            make.left.equalTo(self.mas_left).offset(0);
            make.top.equalTo(self.mas_top).offset(5);
        }];
        
        _twoDLab = [[UILabel alloc] init];
        _twoDLab.textColor = [UIColor orangeColor];
        _twoDLab.text = @"实收房款";
        _twoDLab.textAlignment = NSTextAlignmentCenter;
        _twoDLab.font = [UIFont systemFontOfSize:12];
        [self addSubview:_twoDLab];
        [_twoDLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(AK, 20));
            make.left.equalTo(_oneDLab.mas_right).offset(0);
            make.top.equalTo(self.mas_top).offset(5);
        }];

        _threeDLab = [[UILabel alloc] init];
        _threeDLab.textColor = [UIColor orangeColor];
        _threeDLab.text = @"实收房款";
        _threeDLab.textAlignment = NSTextAlignmentCenter;
        _threeDLab.font = [UIFont systemFontOfSize:12];
        [self addSubview:_threeDLab];
        [_threeDLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(AK, 20));
            make.left.equalTo(_twoDLab.mas_right).offset(0);
            make.top.equalTo(self.mas_top).offset(5);
        }];

      _foreDLab = [[UILabel alloc] init];
        _foreDLab.textColor = [UIColor orangeColor];
        _foreDLab.text = @"实收房款";
        _foreDLab.textAlignment = NSTextAlignmentCenter;
        _foreDLab.font = [UIFont systemFontOfSize:12];
        [self addSubview:_foreDLab];
        [_foreDLab mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.mas_equalTo(CGSizeMake(AK, 20));
           make.left.equalTo(_threeDLab.mas_right).offset(0);
            make.top.equalTo(self.mas_top).offset(5);
        }];

        
    }
    return self;
}
-(void)setupAllCellWithOneLab:(NSString *)_oneLab withTwoLab:(NSString *)_twoLab withThreeLab:(NSString *)_threeLab withForLab:(NSString *)_forLab
{
    _oneDLab.text = _oneLab;
    _twoDLab.text = _twoLab;
    _threeDLab.text = _threeLab;
    
    _foreDLab.text = _forLab;
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
